/*************************************************************************
	> File Name: oj-45.cpp
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
<<<<<<< Updated upstream
	> Created Time: 2020年12月30日 星期三 15时54分59秒
 ************************************************************************/
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    vector<vector<int>> 
    dp(s1.size() + 1, vector<int>(s2.size() + 1, 0));
    for (int i = 1; i <= s1.size(); ++i) {
        for (int j = 1; j <= s2.size(); ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s1[i - 1] == s2[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
=======
	> Created Time: 2020年12月27日 星期日 20时43分52秒
 ************************************************************************/
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define MAX_N 1000
string s1, s2;
int dp[MAX_N + 5][MAX_N + 5];

int main() {
    cin >> s1 >> s2;
    for (int i = 1; i <= s1.size(); ++i) {
        for (int j = 1; j <= s2.size(); ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s1[i - 1] == s2[j - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            }
>>>>>>> Stashed changes
        }
    }
    cout << dp[s1.size()][s2.size()] << endl;
    return 0;
}
